﻿using System;

namespace PrimeNumber.WindowsConsole
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            for (var i = 1; i <= 50; i++)
            {
                if (!IsPrimeNumber(i)) continue;

                Console.WriteLine();
                Console.WriteLine(string.Format("TABLA DEL {0}", i));
                for (var j = 1; j <= 12; j++)
                    Console.WriteLine(string.Format("{0} x {1} = {2}", i, j, i * j));
            }

            Console.Read();
        }

        private static bool IsPrimeNumber(int number)
        {
            var root = Math.Sqrt(number);
            if (root % 1 == 0)
                return false; 

            var limit = Math.Ceiling(root);
            for (int i = 2; i <= limit; i++)
                if (number % i == 0 && number != 2)
                    return false;

            return true;
        }

        //private static bool IsPrimeNumber(int number)
        //{
        //    int dividers = 0;
        //    for (var i = number; i >= 1; i--)
        //        if (number % i == 0)
        //            dividers++;
        //    return dividers == 2;
        //}
    }
}